package ru.sstu.renju.core;

/**
 * {@link Move} class represents single move in Renju game.
 *
 * @author denis_murashev
 * @since Renju 1.0
 */
public class Move {

	private final Game game;
	private final int x;
	private final int y;

	/**
	 * Initializes move.
	 *
	 * @param game game
	 * @param x    x coordinate of cell
	 * @param y    y coordinate of cell
	 */
	public Move(Game game, int x, int y) {
		if (x < 0 || x >= game.getSize() || y < 0 || y >= game.getSize()) {
			throw new IllegalArgumentException();
		}
		this.game = game;
		this.x = x;
		this.y = y;
	}

	/**
	 * @return the game
	 * @since Renju 1.1
	 */
	public Game getGame() {
		return game;
	}

	/**
	 * @return the x
	 */
	public int getX() {
		return x;
	}

	/**
	 * @return the y
	 */
	public int getY() {
		return y;
	}

	@Override
	public String toString() {
		return String.format("(%d, %d)", x, y);
	}
}
